/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
jQuery(document).ready(function(){
    $('.package').click(function(){
        var id = $(this).attr('rel');
        $.ajax({
            type: "POST",
            url : base_url+'?r=shop/shop/result',
            async: false,
            cache: false,
            data: {'id':$(this).attr('rel'), 'type' : $(this).attr('type')
                       },
                            success: function(string){
                                var data = $.parseJSON(string);
                                var content = "";
                                $.each(data, function(index, array) {                              
                                    content = '<div><a class=package ' + ' rel=' + data[index].amount + ' type=1>' + data[index].name + '</a></div>'
                                        + '<div id=category-'+index+'></div>';
                                    $('#package-' + id).after(content);
                                    $('#category-'+index).load(base_url+'?r=shop/shop/distributor', {'name' : data[index].name, 'amount' : data[index].amount});
                                });
                            }
        });
    });
});


